﻿function Img(evt) {
	evt = evt || window.event;

	if (document.all && evt.button != 1) {
		return false;
	}
	
	oX = 2 * document.documentElement.scrollLeft;
	cX = document.documentElement.scrollLeft - window.event.screenX;
	oY = 2 * document.documentElement.scrollTop;
	cY = document.documentElement.scrollTop - window.event.screenY;
	
	if (pic.addEventListener) {
		pic.addEventListener("mousemove", moveHandler, true);
		pic.addEventListener("mouseup", upHandler, true);
	} else if (pic.attachEvent) {
		pic.setCapture( );
		pic.attachEvent("onmousemove", moveHandler);
		pic.attachEvent("onmouseup", upHandler);
		pic.attachEvent("onlosecapture", upHandler);
	} else {
		var oldmovehandler = pic.onmousemove;
		var olduphandler = pic.onmouseup;
		pic.onmousemove = moveHandler;
		pic.onmouseup = upHandler;
	}
	
	if (evt.stopPropagation) evt.stopPropagation( );
	else evt.cancelBubble = true;
	
	if (evt.preventDefault) evt.preventDefault( );
	else evt.returnValue = false;
	
	if (evt.stopPropagation) evt.stopPropagation( );
	else evt.cancelBubble = true;
	
	pic.style.cursor = "move";
	
	function moveHandler(evt) {
		mX = evt.screenX + cX;
		mY = evt.screenY + cY;
		window.scrollTo(oX - mX, oY - mY);
		
		if (evt.stopPropagation) evt.stopPropagation( );
		else evt.cancelBubble = true;
	}
	
	function upHandler(evt) {
		pic.style.cursor = "auto";
		
		if (pic.removeEventListener) {
			pic.removeEventListener("mouseup", upHandler, true);
			pic.removeEventListener("mousemove", moveHandler, true);
		} else if (pic.detachEvent) {
			pic.detachEvent("onlosecapture", upHandler);
			pic.detachEvent("onmouseup", upHandler);
			pic.detachEvent("onmousemove", moveHandler);
			pic.releaseCapture( );
		} else {
			pic.onmouseup = olduphandler;
			pic.onmousemove = oldmovehandler;
		}
		if (evt.stopPropagation) evt.stopPropagation( );
		else evt.cancelBubble = true;
	}
}


var pic = document.getElementById('Img');
pic.onmousedown = Img;

document.onload = self.focus();
